<?php defined('_JEXEC') or die('Restricted access'); 
JHTML::_('behavior.modal');

if( $this->configArray->get('show_import_server', 0) ): ?>

<script type="text/javascript">
window.addEvent('load', function() {

	$('server_import').addEvent('change', function(e)
	{
		var path = $('server_import').getProperty('value');
		$('server_import_link').setProperty('href','index.php?option=com_igallery&controller=igphoto&view=serverimport&catid=<?php echo $this->category->id; ?>&tmpl=component&path=' + path);
	});
});
</script>

<fieldset class="adminform">
<form action="index.php?option=com_igallery&view=serverimport&tmpl=component" method="post" name="serverImport">
<table>
	<tr>
		
		<td>
		<?php echo JText::_( 'IMPORT FROM SERVER' ); ?>:
		</td>
		
		<td>
		<?php echo igHtmlHelper::getFolderList(); ?>
		</td>
		
		<td>
			<a class="modal" id="server_import_link" href="#" rel="{handler: 'iframe', size: {x: 400, y: 300}, onClose: function() {}}">
				<input type="button" name="import_server_button" value="<?php echo JText::_('GO'); ?>" />
			</a>
		</td>	
</tr>
</table>
</form>
</fieldset>
<div class="clr"></div>

<?php endif;?>
		

<form action="index.php" method="post" name="adminForm" id="adminForm">
<fieldset class="adminform">
<legend><?php echo JText::_( 'CURRENT IMAGES' ); ?></legend>

<table>
	<tr>
		<td align="left" width="100%">
			<?php echo JText::_( 'Filter' ); ?>:
			<input type="text" name="search" id="search" value="<?php echo $this->lists['search']; ?>" class="text_area" onchange="document.adminForm.submit();" />
			<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
			<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
		</td>
		<td nowrap="nowrap">
			<?php echo $this->lists['state']; ?>
			<?php echo $this->lists['catid']; ?>
		</td>
	</tr>
</table>

<table class="adminlist">
<thead>
	<tr>
		<th width="5">
			<?php echo JText::_( 'NUM' ); ?>
		</th>

		<th width="20">
			<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
		</th>
		
		<th width="20">
			<?php echo JText::_( 'MENU' ).' '.JText::_( 'IMAGE' )?>
		</th>

		<th class="title" >
			<?php echo JText::_( 'THUMBNAIL' )?>
		</th>

		<th class="title">
			<?php echo JHTML::_('grid.sort', JText::_( 'FILE' ).JText::_( 'NAME' ),
			'filename', $this->lists['order_Dir'], $this->lists['order']); ?>
		</th>

		<th class="title">
			<?php echo JHTML::_('grid.sort', JText::_('MAIN IMAGE FILESIZE'),
			'filesize', $this->lists['order_Dir'], $this->lists['order']); ?>
		</th>
		<!--
		<th class="title">
			<?php echo JHTML::_('grid.sort', JText::_( 'DESCRIPTION' ), 'description',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>
		
		<th class="title">
			<?php echo JHTML::_('grid.sort', JText::_( 'TAGS' ), 'tags',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>

		<th class="title">
			<?php echo JHTML::_('grid.sort', JText::_( 'IMAGE LINK' ), 'link',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>
		
		<th class="title" width="60">
			<?php echo JText::_( 'ROTATE' )?>
		</th>
		-->
		<th width="5%" nowrap="nowrap">
			<?php echo JHTML::_('grid.sort', JText::_( 'PUBLISHED' ), 'published',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>
		
		<th width="5%" nowrap="nowrap">
			<?php echo JHTML::_('grid.sort', JText::_( 'HITS' ), 'hits',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>
		
		<?php if( !empty($this->moderate) ): ?>
		<th width="5%" nowrap="nowrap">
			<?php echo JHTML::_('grid.sort', JText::_( 'MODERATE' ), 'moderate',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>
		<?php endif; ?>
		<!--
		<th width="5%" nowrap="nowrap">
			<?php echo JHTML::_('grid.sort', JText::_( 'ACCESS' ), 'access',
			$this->lists['order_Dir'], $this->lists['order'] ); ?>
		</th>
		-->
		<th width="80" nowrap="nowrap">
			<?php echo JHTML::_('grid.sort',  JText::_( 'ORDER' ), 'ordering',
			$this->lists['order_Dir'], $this->lists['order']); ?>
	 	</th>

		<th width="1%">
			<?php echo JHTML::_('grid.order',  $this->items ); ?>
		</th>
	</tr>
</thead>

<?php $footerColumns = empty($this->moderate) ? 15 : 16; ?>
<tfoot>
	<tr>
	<?php if( !empty($this->catid) ): ?>
		<td colspan="<?php echo $footerColumns; ?>" style="text-align:left">
				<?php echo $this->lists['copy_move']; ?> <?php echo JText::_('SELECTED ITEMS TO'); ?> <?php echo $this->lists['cat_id_copy_move']; ?> 
				<a href="#" onclick="javascript: submitbutton('copy_move')"><input type="button" name="copy_move_button" value="<?php echo JText::_('GO'); ?>" /></a>
		</td>
	<?php endif; ?>
	</tr>
	<tr>
		<td colspan="<?php echo $footerColumns; ?>">
				<?php echo $this->pagination->getListFooter(); ?>
			</td>
		</tr>
</tfoot>

<?php
$k = 0;
for ($i=0; $i<count($this->items); $i++)
{
	$row = &$this->items[$i];
	$editLink 	= JRoute::_( 'index.php?option=com_igallery&amp;controller=igphoto&amp;view=edit_photo&amp;cid[]='. $row->id );
	$catLink 	= JRoute::_( 'index.php?option=com_igallery&amp;controller=igphoto&amp;catid='. $row->gallery_id );
	$checked 	= JHTML::_('grid.id',   $i, $row->id );
	$published 	= JHTML::_('grid.published', $row, $i);
	$moderateImg 	= igHtmlHelper::moderateImage($row, $i, true);

	//get the name of the access group
	$db =& JFactory::getDBO();
	$query = 'SELECT name FROM #__groups where id = '.(int)$row->access;
	$db->setQuery($query);
	$groupNameRow = $db->loadObject();
	$access = $groupNameRow->name;

	?>
	<tr class="<?php echo "row$k"; ?>">
		<td>
			<?php echo $this->pagination->getRowOffset($i); ?>
		</td>

		<td>
			<?php echo $checked; ?>
		</td>
		
		<td>
		<?php if($row->menu_image == 1): ?>
			<a href="index.php?option=com_igallery&amp;controller=igphoto&amp;task=assignMenuImage&amp;catid=<?php echo $row->gallery_id ?>&amp;id=<?php echo $row->id; ?>&amp;cvalue=0">
				<img src="templates/khepri/images/menu/icon-16-default.png" />
			</a>
		<?php else: ?>
			<a href="index.php?option=com_igallery&amp;controller=igphoto&amp;task=assignMenuImage&amp;catid=<?php echo $row->gallery_id ?>&amp;id=<?php echo $row->id; ?>&amp;cvalue=1">
				<img src="../components/com_igallery/images/disabled.png" />
			</a>
		<?php endif; ?>
		</td>

		<td>
			<img src="<?php echo IG_IMAGE_HTML_RESIZE; ?><?php echo $this->thumbFiles[$i]['folderName']; ?>/<?php echo $this->thumbFiles[$i]['fullFileName']; ?>"
			width="<?php echo $this->thumbFiles[$i]['width']; ?>" height="<?php echo $this->thumbFiles[$i]['height'] ?>" alt="<?php echo $row->alt_text; ?>"/>
		</td>
		
		<td align="center">
			<?php echo $row->filename;
			
			if( empty($this->catid) )
			{
				?><br /><a href="<?php echo $catLink;?>"><?php echo $row->name;?></a><?php
			}
			?>
		
		</td>

		<td align="center">
			<?php echo round($this->mainFiles[$i]['filesize']/1000); ?>Kb
		</td>
		<!--
		<td align="center">
			<?php echo $row->description;?> <a href="<?php echo $editLink;?>"><?php echo JText::_( 'EDIT' ); ?></a>
		</td>
		
		<td align="center">
			<?php echo $row->tags;?> <a href="<?php echo $editLink;?>"><?php echo JText::_( 'EDIT' ); ?></a>
		</td>

		<td align="center">
			<?php echo $row->link;?> <a href="<?php echo $editLink;?>"><?php echo JText::_( 'EDIT' ); ?></a>
		</td>
		
		<td>
			<a href="index.php?option=com_igallery&amp;controller=igphoto&amp;task=rotate&amp;catid=<?php echo $row->gallery_id ?>&amp;id=<?php echo $row->id; ?>&amp;rvalue=0">
				<img src="../components/com_igallery/images/rotate-left.png" />
			</a>
		
			<a href="index.php?option=com_igallery&amp;controller=igphoto&amp;task=rotate&amp;catid=<?php echo $row->gallery_id ?>&amp;id=<?php echo $row->id; ?>&amp;rvalue=1">
				<img src="../components/com_igallery/images/rotate-right.png" />
			</a>
		</td>
		-->
		<td align="center">
			<?php echo $published;?>
		</td>
		
		<td align="center">
			<?php echo $row->hits;?>
		</td>
		
		<?php if( !empty($this->moderate) ): ?>
		<td align="center">
			<?php echo $moderateImg; ?>
		</td>	
		<?php endif; ?>
		<!--
		<td align="center">
			<a href="<?php echo $editLink;?>"><?php echo $access;?></a>
		</td>
		-->
		<td class="order" colspan="2">
			<span><?php echo $this->pagination->orderUpIcon($i, true, 'orderup', 'Move Up', isset($this->items[$i-1]) ); ?></span>
            <span><?php echo $this->pagination->orderDownIcon($i, count($this->items), true, 'orderdown', 'Move Down', isset($this->items[$i+1]) ); ?></span>
            <input type="text" name="order[]" size="5" value="<?php echo $row->ordering;?>" class="text_area" style="text-align: center" />
		</td>

	</tr>
	<?php
	$k = 1 - $k;
}
?>

</table>

<input type="hidden" name="option" value="com_igallery" />
<input type="hidden" name="catid" value="<?php echo $this->category->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="igphoto" />
<input type="hidden" name="boxchecked" value="0" />
</fieldset>
</form>

